
var pageCount = 1;
function classOnload(a){
    console.log(a);

//显示所有出差人员
var Json={
    pageIndex:a,
    pageSize:9
}
ajax.post(ajax.myUrl+"trip/tripList",Json,function(result){
    console.log(result);
    response(result);
    // console.log(result.dataset.relaxList);
    var data = result.dataset.relaxList;
    var tbody = document.querySelector("tbody");
    for(var i=0;i<data.length;i++){
        var newtr = document.createElement("tr");
        newtr.innerHTML=`
        <td>${data[i].userId}</td>
        <td>${data[i].businessLocation}</td>
        <td>${data[i].createTime}</td>
        <td>${data[i].endTime}</td>
        <td>${data[i].businessDuration}</td>
        <td>${data[i].relaxDuration}</td>
        `;
        tbody.appendChild(newtr)
    }
})
}
//点击搜索实现按姓名搜索
 var btn = document.querySelector(".search").querySelector("button");
 var inputs = document.querySelector(".search").querySelector("input");
//  var userName =  inputs.value;
 
 btn.onclick = function(){
    console.log(inputs.value)
    var Json2={
        userName:inputs.value,
        pageIndex:1,
        pageSize:1
    }
    ajax.post(ajax.myUrl+"trip/tripList",Json2,function(result){
    console.log(result.dataset.relaxList);
    var data = result.dataset.relaxList;
    if(data.length==0){
        alert("该用户不存在,请重新输入");
    }
    var tbody = document.querySelector("tbody");
    for(var i=0;i<data.length;i++){
        tbody.innerHTML=`<tr>
                            <td>${data[i].userId}</td>
                            <td>${data[i].businessLocation}</td>
                            <td>${data[i].createTime}</td>
                            <td>${data[i].endTime}</td>
                            <td>${data[i].businessDuration}</td>
                            <td>${data[i].relaxDuration}</td>
                        </tr>`
    }
 })
}
//点击出差，弹出模态框
//获取模态框
var goOut = document.getElementsByClassName("goOut")[0];
var addition = document.getElementsByClassName("addition")[0];
var apply = addition.getElementsByClassName("apply")[0];
apply.onclick = function(){
    goOut.style.display = "block";
}

//点击申请模态框中的确定或取消，模态框消失
var sure = document.getElementsByClassName("sure")[0];
sure.onclick = function(){
    goOut.style.display = "none";
}
var cancel = document.getElementsByClassName("cancel")[0];
cancel.onclick = function(){
    goOut.style.display = "none";
}
var dailyTime = document.getElementById("dailyTime");
var nowTime = new Date();
var year = nowTime.getFullYear();
var month = nowTime.getMonth()+1;
var day = nowTime.getDate();
var hour = nowTime.getHours();
var minutes = nowTime.getMinutes();
if(month<10){
    month="0"+month;
}
dailyTime.setAttribute("value",year+"-"+month+"-"+day);